#!/bin/bash

echo "Habilitando ftrace"
echo sched_switch > /sys/kernel/debug/current_tracer
echo 1 > /sys/kernel/debug/tracing_enable

for ((i = 0; i < 100; i++ ))
do
  echo "Iniciando processo qualquer $i"
  ./processo_qualquer &
done

echo "Iniciando processo rt"
./processo_rt

echo "Desabilitando ftrace"
echo 0 > /sys/kernel/debug/tracing_enable

kill -9 `ps uwax | grep processo_qualquer | grep -v grep | gawk '{print $2;}'`
kill -9 `ps uwax | grep processo_rt | grep -v grep | gawk '{print $2;}'`

cat /sys/kernel/debug/trace > trace

echo "Filtrando ftrace"
./filtra_trace.tcl trace > log
